﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SheepStorage.API.Application.Command.SheepDeathCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace SheepStorage.API.Controllers
{
    /// <summary>
    /// 羊只死亡
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SheepDeathController : ControllerBase
    {
        private readonly IMediator _mediator;
        private readonly ISheepDeathService _deathServ;

        public SheepDeathController(IMediator mediator, ISheepDeathService deathServ)
        {
            _mediator = mediator;
            _deathServ = deathServ;
        }
        /// <summary>
        /// 死亡列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]

        public async Task<Results<Domain.DTO.Output.PageOutput<SheepDeathOutput>>> GetSheepDeaths(SheepDeathSelectCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 死亡添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> AddSheepDeaths(SheepDeathAddCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 死亡删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> DelSheepDeaths(SheepDeathDeleteCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> BatchDelSheepDeaths(SheepDeathBatchDelCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 反填死亡信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<SheepDeath>> GetSheepDeath(SheepDeathEditCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 修改死亡信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Results<int>> UpdSheepDeaths(SheepDeathUpdateCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
